require 'net/telnet'

#
# CPL Assignment 2
# Tim Caljé, Jeroen De Raedt & Jorick Van Aken
#
class Connection
  
  def initialize
    @host = "localhost"
    @port = 12111
  end
  
  def query(query)
    host = Net::Telnet.new("Host" => @host, "Port" =>  @port)
    results = nil
    host.cmd(query){ |c| results  = c;}
    if(results == nil)  
      results = ""
    else
      results = results.split("/n").join()
    end
    host.close
    results
  end
end